JournalRepository

@Singleton
class JournalRepository @Inject constructor(journalRemoteDataSource: JournalRemoteDataSource)

Repository class responsible for handling operations related to journal entries. It acts as a bridge between the data source and the rest of the application, providing methods to add, update, delete, and fetch journal entries.

Constructors

Link copied to clipboard
@Inject
constructor(journalRemoteDataSource: JournalRemoteDataSource)

Functions

Link copied to clipboard
suspend fun addJournalEntry(journalEntry: JournalEntry)

Adds a new journal entry to the Firestore database.

Link copied to clipboard
suspend fun deleteJournalEntry(journalEntry: JournalEntry)

Deletes a journal entry using the provided JournalEntry object.

suspend fun deleteJournalEntry(id: String)

Deletes a journal entry by its ID.

Link copied to clipboard

Returns a Flow that emits a list of journal entries in real-time, listening for updates from Firestore.

Link copied to clipboard
suspend fun updateMoodEntry(journalEntry: JournalEntry)

Updates an existing journal entry in the Firestore database. If the entry does not exist, it will be added.